<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
<title>找回密码</title>
<link rel="stylesheet" href="<?php echo $_BASE_DIR ?>baodan/css/common.css" >
<link rel="stylesheet" href="<?php echo $_BASE_DIR ?>baodan/css/register.css" >
<script type="text/javascript" src="<?php echo $_BASE_DIR ?>baodan/js/jquery-3.1.1.min.js"></script>
<style>
	.login-footer{width:84%;position: fixed;bottom: 70px;left: 8%;z-index: 33;height:94px;}
	.third-party{ font-size: 14px; text-align: center; color:#b3b3b3;}
	.third-party span{ padding:0 12px; background-color: #fff; text-align: center;}
	.devide-line{ width:100%;height:1px;background-color: #ccc; top:10px; position: absolute; left:0;  z-index: -10;}
	.wechat-login{display: block;margin:25px auto 0;width:48px;height:48px;}

</style>

</head>

<body>
<header class="header">
    <a class="back" href="javascript:history.back(-1)"></a>
	<div class="title">找回密码</div>
</header>
<div style="height:40px;"></div>


<ul class="login">

  <li id="username"><span>账  号：</span><input type="text"  name="username" id= "mobile" value=""  placeholder="请输入您的手机号" /></li>
  <li id="yanzma"><span>验证码：</span><input type="text"  name="username"  id="checkcode" value=""  placeholder="请输入验证码" />

 	<input type="button"  id="getcode" onclick="getCatpcha()" name="getcode" id="getcode" value="获取验证码" 
 	style="float: right;
    font-size: 14px;
    margin-top: -30px;
    color: #4a79e2;"/> 
  </li>
  <li id="password"><span>密  码：</span><input type="password" name="password"  id="password" value=""  placeholder="请输入密码" /></li>
  <li><span >确认密码：</span>
  <input type="password" name="password"  id="confirmpass" value=""  placeholder="请再次输入密码" /></li>
  
</ul>
<div class="log-on">
    <ul>
		<li><a  href="javascript:void(0)" onclick="reg();"><p>确 定</p></a></li>
    </ul>
</div>

<script type="text/javascript">
	var count = 30;
	function isMobile(value) {
    if (/^[0]?1[345678]\d{9}$/g.test(value)) {
        return true;
    } else {
        return false;
    }
}

function timecount(){	 
	 var countdown = setInterval(function(){
			$("#getcode").attr("disabled", true); 
			$("#getcode").val("请等待 " + count + "秒"); 
			if (count == 0) { 
			$("#getcode").val("获取验证码").removeAttr("disabled"); 
			clearInterval(countdown); 
			return false;
			} 
			count--; 			
		 }, 1000);		
}


function reg()
{
	var phone = $('#mobile').val();
	
	var password = $("#password").val();
	var confirmpass = $("#confirmpass").val();
	
	var checkcode = $("#checkcode").val();

	if (password.length < 6 || password.length > 20) {
		
		alert("密码是6~20位数字或者字母!");
		return false;
	}
	if (password != confirmpass) {
		alert("确认密码与密码不一致");
	   return false;
	}

	    if (phone == '') {
           alert("请输入手机号！");
            return false;
        }
		if (!isMobile(phone)) {
			alert("手机号格式不正确");
		   return false;
		}

	var ajaxurl = "/baodan/forgetpwd";
	$.post(ajaxurl, {
		phone: phone,
		checkcode: checkcode,
		password:password,
	}, function(data){
		
		if(data.code == 0){
			alert(data.msg);
	 		location.href=data.msg;
			return false;	
		}else{
			alert(data.msg);
			 return false;	
		}
	}, 'json');
}

	
function getCatpcha(){
	
		var phone = $('#mobile').val();
		 if (phone == '') {
            alert("请输入手机号！");
            return false;
        }
		if (!isMobile(phone)) {
			alert("手机号格式不正确");
		   return false;
		}
	 timecount();	
	var ajaxurl = "/baodan/getCatpcha";
	$.post(ajaxurl, {
		phone: phone,
		op:'findpwd',
	}, function(data){
		alert(data.msg);
	    return false;	
	}, 'json');
}
</script>


</body>
</html>
